// 导入 post 和 get 方法，用于发送 POST 和 GET 请求
import { post, get } from "./service.js"

// 登录接口
export const loginApi = data => {
    return post({
        url: '/api/login',
        data
    })
}

// 注册接口
export const registerApi = data => {
    return post({
        url: '/api/reguser',
        data
    })
}

// 获取所有绘画图片接口
export const getDrawAllImages = () => {
    return get({
        url: '/upload/draw',
    });
}

// 获取所有留言内容接口
export const getArticlesContent = () => {
    return get({
        url: '/my/article/ArticlesContent',
    });
}

// 获取所有留言接口
export const getArticles = () => {
    return get({
        url: '/my/article/Articles',
    });
}

// 根据留言ID获取评论接口
export const getCommentsByArticleId = (articleId) => {
    return get({
        url: '/my/article/Comments',
        params: {
            articleId: articleId
        }
    });
}

// 点赞留言接口
export const likeArticle = (articleId) => {
    return post({
        url: '/my/article/likeArticle',
        data: {
            articleId: articleId
        }
    });
}

// 点赞评论接口
export const likeCommentAPI = (commentId) => {
    return post({
        url: '/my/article/likeComment',
        data: {
            commentId: commentId
        }
    });
}

// 删除留言接口
export const deleteArticleAPI = (articleId, username) => {
    return post({
        url: '/my/article/deleteArticles',
        data: {
            articleId: articleId,
            username: username
        }
    });
}

// 添加留言接口
export const addArticles = (title, content, author_id) => {
    return post({
        url: '/my/article/addArticles',
        data: {
            title: title,
            content: content,
            author_id: author_id
        }
    });
}

// 添加评论接口
export const addComments = (article_id, user_id, content, parent_comment_id) => {
    return post({
        url: '/my/article/addComments',
        data: {
            article_id: article_id,
            user_id: user_id,
            content: content,
            parent_comment_id: parent_comment_id
        }
    })
}

// 搜索留言接口
export const searchArticles = (keyword) => {
    return get({
        url: '/my/article/searchArticles',
        params: {
            keyword: keyword
        }
    })
}

// 根据用户ID获取用户信息接口
export const getUserInfoById = (id) => {
    return get({
        url: '/my/article/getUserInfoById',
        params: {
            id: id
        }
    })
}

// 获取当前用户信息接口
export const getUserInfo = () => {
    return get({
        url: '/my/userinfo'
    })
}

//修改用户信息接口
export const updateUserInfo = (data) => {
    return post({
        url: '/my/userinfo',
        data: data
    })
}

//修改用户密码接口
export const updatePassword = (data) => {
    return post({
        url: '/my/updatepwd',
        data: data
    })
}

